using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.ComponentModel;
using CS6238Project2.Banking.Commerce;
using CS6238Project2.Banking.Communication;


namespace CS6238Project2.Banking.Commerce
{
    /// <summary>
    /// Held by banks, contains money, transaction record, and authorization
    /// certificates
    /// </summary>
    [Serializable]
    public partial class Account : IComparable
    {
        private int number;//account number
        private int balance;
        private string name;
        private BindingList<Communication.Transaction> record;

        /// <summary>
        /// Default constructor creates null/default values throughout the account structure.
        /// </summary>
        public Account()
        {
            number = -1;
            balance = 2000;
            record = new BindingList<CS6238Project2.Banking.Communication.Transaction>();
        }

        public Account(String userName, int numb)
        {
            name = userName;
            balance = 2000;
            number = numb;
            record = new BindingList<CS6238Project2.Banking.Communication.Transaction>();
            //record.AddNew(new Transaction("Bank", "Bank", numb, 2000, DateTime.Now));
            Transaction newTransaction = record.AddNew();
            newTransaction.Requester = "Bank";
            newTransaction.Authorizer = "Bank";
            newTransaction.Account = numb;
            newTransaction.Adjustment = 2000;
            newTransaction.Timestamp = DateTime.Now;
        }

        



        /// <summary>
        /// The account number
        /// </summary>
        public int Number
        {
            get { return number; }
            set { number = value; }
        }
        /// <summary>
        /// The amount of money in the account
        /// </summary>
        public int Balance
        {
            get { return balance;  }
            set { balance = value; }
        }
        /// <summary>
        /// The record of transactions
        /// </summary>
        public BindingList<Communication.Transaction> Record
        {
            get { return record; }
            set { record = value; }
        }
        /// <summary>
        /// Name associated with the user.
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

    }
}
